﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Cosmetic.Logic;
using System.Collections.Generic;
using Cosmetic.DataEntity;

namespace WebApp.Controls
{
    public partial class ThemePlate2 : System.Web.UI.UserControl
    {
        PlateManager PM = new PlateManager();
        AdvertiseManager theAdvertiseManager = new AdvertiseManager();

        protected void Page_Load(object sender, EventArgs e)
        {
            this.ListView1.DataSource = PM.GetPlateCloth();
            this.ListView1.DataBind();
            BindTopLinks();
            BindImage();
            //BindBottomAd();
        }

        protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            HyperLink hl = e.Item.FindControl("HyperLink1") as HyperLink;
            if (hl.Text.Length > 8)
            {
                hl.Text = hl.Text.Substring(0, 8);
            }
        }

        private void BindImage()
        {
            Cosmetic.DataEntity.PlateExcellentClothBigPic pjc = theAdvertiseManager.GetPlateClothBigPic();
            this.imgBigPic.ImageUrl = pjc.PicUrl;
            //this.HyperLink5.NavigateUrl = pjc.PicUrl;
        }
        private void BindTopLinks()
        {
            List<Cosmetic.DataEntity.PlateExcellentClothPlaceHolder> listHolder = theAdvertiseManager.GetPlateClothPlaceHolderTOP();
            this.rptTopLink.DataSource = listHolder;
            this.rptTopLink.DataBind();
        }
        //private void BindBottomAd()
        //{
        //    Cosmetic.DataEntity.PlateExcellentClothBigPic pjc = theAdvertiseManager.GetPlateClothBigPic();

        //    List<Cosmetic.DataEntity.PlateExcellentClothPlaceHolder> listHolder = theAdvertiseManager.GetPlateClothPlaceHolderLEFT();
        //    if (!pjc.IsLeftPositionPic.Value)
        //    {
        //        List<Cosmetic.DataEntity.PlateExcellentClothPlaceHolder> listNotPic = listHolder.Where(c => c.IsPic != true).ToList();
        //        rptLeftLinks.DataSource = listNotPic;
        //        rptLeftLinks.DataBind();
        //        this.PLLeftPic.Visible = false;
        //        this.PLRightLinks.Visible = true;
        //    }
        //    else
        //    {
        //        List<Cosmetic.DataEntity.PlateExcellentClothPlaceHolder> listPic = listHolder.Where(c => c.IsPic == true).ToList();
        //        PlateExcellentClothPlaceHolder pjcp = listPic.First();
        //        this.imgLeftPic.ImageUrl = pjcp.PicUrl;

        //        this.PLLeftPic.Visible = true;
        //        this.PLRightLinks.Visible = false;
        //    }



        //    List<Cosmetic.DataEntity.PlateExcellentClothPlaceHolder> listHolderRight = theAdvertiseManager.GetPlateClothPlaceHolderRIGHT();

        //    if (!pjc.IsRightPositionPic.Value)
        //    {
        //        List<Cosmetic.DataEntity.PlateExcellentClothPlaceHolder> listNotPic = listHolderRight.Where(c => c.IsPic != true).ToList();
        //        rptRightLinks.DataSource = listNotPic;
        //        rptRightLinks.DataBind();
        //        this.PLRightPic.Visible = false;
        //        this.PLRightLinks.Visible = true;
        //    }
        //    else
        //    {
        //        List<Cosmetic.DataEntity.PlateExcellentClothPlaceHolder> listPic = listHolderRight.Where(c => c.IsPic == true).ToList();
        //        PlateExcellentClothPlaceHolder pjcp = listPic.First();
        //        this.imgRightPic.ImageUrl = pjcp.PicUrl;

        //        this.PLRightPic.Visible = true;
        //        this.PLRightLinks.Visible = false;
        //    }
        //}
    }
}